-- cmd_direct_buy_goods
-- Create by huanghr
-- 直接购买金币或者遗迹碎片

function Operation.cmd_direct_buy_goods(buyType, gemAmount, buyAmount)

    -- 暂时默认只有属性
    local attrib = "gem";
    if ME.user:queryAttrib(attrib) < gemAmount then
        return;
    end

    -- 扣除属性
    ME.user:costAttrib(attrib, gemAmount);

    -- 奖励
    local bonus;

    if buyType == "money" then
        bonus = {2, "money", buyAmount};
    else
        bonus = {1, 10000, buyAmount};
    end

    BonusM.doBonus(bonus, "direct_buy_goods");

    -- 抛出事件
    EventMgr.fire(event.DIRECT_BUY_GOODS, {["bonus"] = bonus});

    -- 找零奖励
    local v = {
        ["buy_type"] = buyType,
        ["gem_cost"] = gemAmount,
    };

    SyncM.addMessage("CMD_DIRECT_BUY_GOODS", v);

    -- TODO:
    SyncM.startSync();
end